package com.gdou.controller;


import com.gdou.commons.Result;
import com.gdou.service.EcharsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/echars")
public class EcharsController {

    @Autowired
    private EcharsService echarsService;

    @RequestMapping("/getShipWithUserCount")
    public Result getShipWithUserCount(){
        return echarsService.findShipWithUserCount();
    }


    // 获取所有的数据
    @RequestMapping("/getShipAllInfoById")
    public Result getShipAllInfoById(Long shipId){
        if (shipId==null || shipId<1){
            return Result.DATA_FORMAT_ERROR;
        }
        return echarsService.findAllInfoByShipId(shipId);
    }

    /*温度*/
    @RequestMapping("/getShipTemperatureById")
    public Result getShipTemperatureById(Long shipId){
        if (shipId==null || shipId<1){
            return Result.DATA_FORMAT_ERROR;
        }
        return echarsService.findTemperaturesByShipId(shipId);
    }

    // 湿度
    @RequestMapping("/getShipHumidityById")
    public Result getShipHumidityById(Long shipId){
        System.out.println("--访问到了");
        if (shipId==null || shipId<1){
            return Result.DATA_FORMAT_ERROR;
        }
        return echarsService.findHumiditiesByShipId(shipId);
    }
    // 剩余油量

}
